﻿using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Windows.Input;
using System.Windows.Forms;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UITest.Extension;
using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;


namespace Emotive.SolutionUI.Test
{
    /// <summary>
    /// Summary description for CodedUITest1
    /// </summary>
    [CodedUITest]
    public class SolutionUI
    {
        public SolutionUI()
        {
        }

        [TestMethod]
        public void StartDesigner()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.StartDesigner();
        }

        [TestMethod]
        public void AddNewSolNewProj()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddNewSol();
            this.UIMap.CheckNewSol();
            this.UIMap.AddNewProj();
            this.UIMap.CheckNewProj();
            this.UIMap.CheckProcMain();
        }

        [TestMethod]
        public void AddNewSolWithProj()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddNewSolWithProj();
            this.UIMap.CheckNewSolWithProj();
            this.UIMap.CheckNewProj_A();
            this.UIMap.CheckProcMain_A();
        }

        [TestMethod]
        public void ReloadSol()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.ReloadNewSolWithProj();
            this.UIMap.CheckNewSolWithProj();
            this.UIMap.CheckNewProj_A();
            this.UIMap.CheckProcMain_A();
        }

        [TestMethod]
        public void AddNewSolWithSameName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddNewSolWithProj_A();
            this.UIMap.CheckCanNotAddIdenticalSol();
            this.UIMap.AddNewSolWithProj_B();
            this.UIMap.CheckCanNotAddIdenticalSolWithProj();
            this.UIMap.CloseErrorDialog();
            this.UIMap.CancelAddNewSolWithProj();
        }

        [TestMethod]
        public void AddNewSolNotCreatedPath()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddNewSol1();
            this.UIMap.CheckNewSol1();
            this.UIMap.AddNewSol2();
            this.UIMap.CheckNewSol2();
        }

        [TestMethod]
        public void AddNewSolWrongPath()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463           
            this.UIMap.AddNewSol3();
            this.UIMap.CheckAddSolWrongPath();
            this.UIMap.ClickOKWrongPathError();
            this.UIMap.ClickCancelAddSolution();
            this.UIMap.AddNewSol4();
            this.UIMap.CheckAddSolWrongPath_A();
            this.UIMap.ClickOKWrongPathError();
            this.UIMap.ClickCancelAddSolution_A();

            //this.UIMap.ClickCancelAddSolution();
            // chua lam xong
        }


        [TestMethod]
        public void LoadSolWithNonexistentProj()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.LoadSolWithNonexistentProj();
            this.UIMap.CheckSolWithNonexistentProj();
            this.UIMap.OpenSolWithNonexistentProjProcMain();
            //this.UIMap.CheckSolNonexistentProjProcMainOpened();
        }

        [TestMethod]
        public void ValidateSol()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.LoadSolValidation();
            this.UIMap.CheckSolValidation();
            this.UIMap.ValidateSolValidation();
            this.UIMap.CheckErrorNum();
            this.UIMap.CheckWarningNum();
        }

        [TestMethod]
        public void CheckAutoReloadSol()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.LoadSolSample();
            this.UIMap.OpenSampleProcMain();
            //chua lam xong, do ko dong dc designer
        }

        [TestMethod]
        public void CloseSol()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
        }

        #region Additional test attributes

        // You can use the following additional attributes as you write your tests:

        ////Use TestInitialize to run code before running each test 
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{        
        //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
        //    // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
        //}

        ////Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{        
        //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
        //    // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
        //}

        #endregion

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
        private TestContext testContextInstance;

        public UIMap UIMap
        {
            get
            {
                if ((this.map == null))
                {
                    this.map = new UIMap();
                }

                return this.map;
            }
        }

        private UIMap map;
    }
}
